/**
 * @Creator: eyes
 * @Date: 2019/12/23
 * 性能统计可视化-相关 API mock
 */

const { mock, Random } = require("mockjs");
const trendDetail = require('./json/performance/trendDetail.json');
const trend = require('./json/analysis/trend.json');
const success = require('./json/success.json');

module.exports = {
    "POST /api/performance/corepage": mock({
        code: 0,
        msg: null,
        data: {
            performanceMeasures: [1, 2, 3, 4, 5, 6, 7].map(_ => ({
                datetime: `2020-10-0${_} 00:00:00`,
                targetAvg: Random.integer(1, 100),
                target85th: Random.integer(1, 100),
                target90th: Random.integer(1, 100),
                target95th: Random.integer(1, 100)
            }))
        },
        pager: {
            pageNum: 1,
            pageSize: 50,
            count: 100
        }
    }),
    // 获取性能总体特征周环比
    "POST /api/performance/analysis/feature": {
        code: 0,
        msg: null,
        data: {
            featurePanel: {
                value: 1616,
                wowRatio: 14.23,
                pv: 3322
            },
            msg: null
        }
    },
    "POST /api/performance/field/values": (req, res) => {
        // 业务线enum
        if (req.body.field === "biz_type_name") {
            return res.json({
                code: 0,
                msg: null,
                data: {
                    values: [
                        "serviceLine1",
                        "serviceLine2",
                        "serviceLine3",
                        "serviceLine4"
                    ]
                },
                pager: {
                    pageNum: 1,
                    pageSize: 50,
                    count: 100
                }
            });
        } else if (req.body.field === "biz_name") {
            //应用enum
            return res.json({
                code: 0,
                msg: null,
                data: {
                    values: ["app1", "app2", "app3", "app4"]
                },
                pager: {
                    pageNum: 1,
                    pageSize: 50,
                    count: 100
                }
            });
        }
        const paths = [];
        for(let i = 0; i < 200; i++) {
            paths.push(`path${i}`);
        }
        return res.json({
            code: 0,
            msg: null,
            data: {
                values: paths
            },
            pager: {
                pageNum: 1,
                pageSize: 50,
                count: 100
            }
        });
    },
    "POST /api/performance/analysis/rank": mock({
        code: 0,
        msg: null,
        data: {
            measureRankDetails: [1, 2, 3, 4, 5, 6, 7].map(_ => ({
                key: _,
                bizTypeName: "serviceLine1",
                bizName: "app1",
                path: "/gaotu/haoke",
                value: 100
            }))
        },
        pager: {
            pageNum: 1,
            pageSize: 50,
            count: 100
        }
    }),
    // 性能分析 - 趋势
    "POST /api/performance/analysis/trend": trend,
    // 性能分析 - 趋势 更多
    "POST /api/performance/analysis/trend/detail": trendDetail,
    "POST /api/performance/analysis/distribution": mock({"code":0,"data":{"distributions":[{"datetime":"0","include":"5","value":8947,"fieldValue":null},{"datetime":"100","include":"5","value":5107,"fieldValue":null},{"datetime":"200","include":"5","value":1288,"fieldValue":null},{"datetime":"300","include":"5","value":462,"fieldValue":null},{"datetime":"400","include":"5","value":287,"fieldValue":null},{"datetime":"500","include":"5","value":271,"fieldValue":null},{"datetime":"600","include":"5","value":214,"fieldValue":null},{"datetime":"700","include":"5","value":190,"fieldValue":null},{"datetime":"800","include":"5","value":105,"fieldValue":null},{"datetime":"900","include":"5","value":86,"fieldValue":null},{"datetime":"1000","include":"5","value":54,"fieldValue":null},{"datetime":"1100","include":"5","value":54,"fieldValue":null},{"datetime":"1200","include":"5","value":37,"fieldValue":null},{"datetime":"1300","include":"5","value":31,"fieldValue":null},{"datetime":"1400","include":"5","value":34,"fieldValue":null},{"datetime":"1500","include":"5","value":25,"fieldValue":null},{"datetime":"1600","include":"5","value":21,"fieldValue":null},{"datetime":"1700","include":"5","value":27,"fieldValue":null},{"datetime":"1800","include":"5","value":10,"fieldValue":null},{"datetime":"1900","include":"5","value":14,"fieldValue":null},{"datetime":"2000","include":"5","value":15,"fieldValue":null},{"datetime":"2100","include":"5","value":13,"fieldValue":null},{"datetime":"2200","include":"5","value":14,"fieldValue":null},{"datetime":"2300","include":"5","value":9,"fieldValue":null},{"datetime":"2400","include":"5","value":4,"fieldValue":null},{"datetime":"2500","include":"5","value":4,"fieldValue":null},{"datetime":"2600","include":"5","value":7,"fieldValue":null},{"datetime":"2700","include":"5","value":8,"fieldValue":null},{"datetime":"2800","include":"5","value":7,"fieldValue":null},{"datetime":"2900","include":"5","value":7,"fieldValue":null},{"datetime":"3000","include":"5","value":2,"fieldValue":null},{"datetime":"3100","include":"5","value":5,"fieldValue":null},{"datetime":"3200","include":"5","value":5,"fieldValue":null},{"datetime":"3300","include":"5","value":3,"fieldValue":null},{"datetime":"3400","include":"5","value":3,"fieldValue":null},{"datetime":"3500","include":"5","value":2,"fieldValue":null},{"datetime":"3600","include":"5","value":3,"fieldValue":null},{"datetime":"3800","include":"5","value":5,"fieldValue":null},{"datetime":"3900","include":"5","value":3,"fieldValue":null},{"datetime":"4000","include":"5","value":4,"fieldValue":null},{"datetime":"4100","include":"5","value":3,"fieldValue":null},{"datetime":"4200","include":"5","value":2,"fieldValue":null},{"datetime":"4300","include":"5","value":3,"fieldValue":null},{"datetime":"4400","include":"5","value":1,"fieldValue":null},{"datetime":"4500","include":"5","value":3,"fieldValue":null},{"datetime":"4700","include":"5","value":4,"fieldValue":null},{"datetime":"4800","include":"5","value":2,"fieldValue":null},{"datetime":"4900","include":"5","value":2,"fieldValue":null},{"datetime":"5000","include":"5","value":2,"fieldValue":null},{"datetime":"5100","include":"5","value":4,"fieldValue":null},{"datetime":"5500","include":"5","value":1,"fieldValue":null},{"datetime":"5600","include":"5","value":1,"fieldValue":null},{"datetime":"5700","include":"5","value":2,"fieldValue":null},{"datetime":"5900","include":"5","value":1,"fieldValue":null},{"datetime":"6100","include":"5","value":1,"fieldValue":null},{"datetime":"6300","include":"5","value":1,"fieldValue":null},{"datetime":"6400","include":"5","value":2,"fieldValue":null},{"datetime":"6500","include":"5","value":1,"fieldValue":null},{"datetime":"6900","include":"5","value":3,"fieldValue":null},{"datetime":"7000","include":"5","value":1,"fieldValue":null},{"datetime":"7100","include":"5","value":1,"fieldValue":null},{"datetime":"7400","include":"5","value":1,"fieldValue":null},{"datetime":"7600","include":"5","value":1,"fieldValue":null},{"datetime":"7700","include":"5","value":1,"fieldValue":null},{"datetime":"7900","include":"5","value":1,"fieldValue":null},{"datetime":"8000","include":"5","value":1,"fieldValue":null},{"datetime":"8600","include":"5","value":2,"fieldValue":null},{"datetime":"8700","include":"5","value":1,"fieldValue":null},{"datetime":"9100","include":"5","value":1,"fieldValue":null},{"datetime":"9200","include":"5","value":1,"fieldValue":null},{"datetime":"9700","include":"5","value":2,"fieldValue":null},{"datetime":"9900","include":"5","value":1,"fieldValue":null}]},"msg":"success","pager":null}),
    //查询按重要性排序好的路径指标
    "POST /api/performance/analysis/targetImportance": mock({
        code: 0,
        data: {
            sortedTargetTypes: [11, 10, 9, 1, 2, 3, 4, 5, 6, 7, 8, 13]
        },
        msg: "success",
        pager: null
    }),
    // 用户特征-分页用户清单
    "POST /api/performance/user/feature/list": mock({
        code: 0,
        data: {
            userDetails: [
                {
                    datetime: "2020-05-20 23:32:24",
                    userId: "-1",
                    bizTypeName: "高途",
                    bizName: "gt-m",
                    path: "/",
                    province: "辽宁",
                    city: "沈阳",
                    carrier: "移动",
                    netType: "Wifi",
                    os: "Android",
                    osVersion: "Android 8.1.0",
                    brandVersion: "mi play",
                    fsp: 0,
                    fi: 0,
                    fr: 1.1,
                    ttfp: 926,
                    resp: 41,
                    tree: 1101,
                    ready: 760,
                    ttfb: "50",
                    ttsr: "178",
                    dns: "0",
                    tcp: 0
                },
                {
                    datetime: "2020-05-20 23:33:58",
                    userId: "-1",
                    bizTypeName: "高途",
                    bizName: "gt-m",
                    path: "/",
                    province: "广东",
                    city: "深圳",
                    carrier: "移动",
                    netType: "Wifi",
                    os: "iOS",
                    osVersion: "iOS 13.4.1",
                    brandVersion: "iphone",
                    fsp: 0,
                    fi: 0,
                    fr: 1.1,
                    ttfp: 494,
                    resp: 52,
                    tree: 417,
                    ready: 224,
                    ttfb: "70",
                    ttsr: "76",
                    dns: "0",
                    tcp: 0
                }
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 127508 }
    }),
    "POST /api/performance/user/feature/area": success,
    // 查看已配置的应用
    "POST /api/performance/preference/getBizPreference": mock({
        code: 0,
        data: {
            bizPreferences: [
                {
                    bizTypeName: '高途',
                    bizName: 'gt-mhk-m',
                    bizId: 111
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },{
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-pc',
                    bizId: 113
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-mobile',
                    bizId: 114
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-data',
                    bizId: 115
                }
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),
    // 用户配置：查看已配置path-指标组合
    "POST /api/performance/preference/getTargetPreference": mock({
        code: 0,
        data: {
            targetPreferences: [
                {
                    path: '/',
                    targetType: 1,
                    targetId: 123
                },
                {
                    path: '/gt-m',
                    targetType: 11,
                    targetId: 3212
                }
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),
    // 用户配置：添加组合
    "POST /api/performance/preference/addPreference": mock({
        code: 0,
        data: {
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),
    // 用户配置: 删除配置
    "POST /api/performance/preference/deleteTarget": mock({
        code: 0,
        data: {
            targetPreferences: [
                {
                    path: '/',
                    targetType: 1,
                    targetId: 123
                }
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),

    // 用户配置：业务线-应用组合重排序
    "POST /api/performance/preference/reorderBizName": mock({
        code: 0,
        data: {
            bizPreferences: [
                {
                    bizTypeName: '高途',
                    bizName: 'gt-mhk-m',
                    bizId: 111
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-pc',
                    bizId: 113
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    bizId: 112
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-mobile',
                    bizId: 114
                },
                {
                    bizTypeName: '高途',
                    bizName: 'gt-data',
                    bizId: 115
                }
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),
    // 用户配置：路径-指标组合重排序
    "POST /api/performance/preference/reorderTarget": mock({
        code: 0,
        data: {
            targetPreferences: [
                {
                    path: '/gt-m',
                    targetType: 11,
                    targetId: 3212
                },
                {
                    path: '/',
                    targetType: 1,
                    targetId: 123
                },
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),
    // 核心页面：找到所有用户配置
    "POST /api/performance/preference/getAllPreference": mock({
        code: 0,
        data: {
            fullPreferences: [
                {
                    targetType: 11,
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    path: '/',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    path: '/learn/',
                },
                {
                    targetType: 9,
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    path: '/study',
                },
                {
                    targetType: 4,
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    path: '/study/test/testestsetsetset.12313estsetsetset.12313estsetsetset.12313estsetsetset.12313',
                },
                {
                    targetType: 2,
                    bizTypeName: '高途',
                    bizName: 'gt-m',
                    path: '/study',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-activity-end',
                    path: '/Criss/lijian',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-activity-end',
                    path: '/Criss/lijian02',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-activity-end',
                    path: '/Criss/lijian03',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-itive-student',
                    path: '/newExercise/pc',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-itive-student',
                    path: '/newExercise/android',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-itive-student',
                    path: '/newExercise/ios',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-itive-student',
                    path: '/newBeforeExercise/pc',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-itive-student',
                    path: '/newBeforeExercise/android',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-itive-student',
                    path: '/newBeforeExercise/ios',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-cw-cocos',
                    path: '/grade_spring20/android',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-cw-cocos',
                    path: '/grade_spring20/ios',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-cw-cocos',
                    path: '/grade_spring20/pc',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-cw-cocostpl',
                    path: '/grade_template19/android',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-cw-cocostpl',
                    path: '/grade_template19/ios',
                },
                {
                    targetType: 10,
                    bizTypeName: '高途',
                    bizName: 'gt-cw-cocostpl',
                    path: '/grade_template19/pc',
                }
            ]
        },
        msg: "success",
        pager: { pageSize: 10, pageNum: 1, count: 200 }
    }),
    "POST /api/performance/preference/checkForDup": mock({
        code: 0,
        data: true,
        msg: 'success'
    }),
    "POST /api/performance/preference/getBizInPage": mock({
        code: 0,
        data: ['gt-m', 'gt-activity-end', 'gt-cw-cocostpl', 'gt-itive-student', 'gt-cw-cocos'],
        msg: 'success'
    })
};
